package com.sacc.controller;

import com.power.common.model.CommonResult;
import com.sacc.pojo.BoxAdopted;
import com.sacc.service.BoxAdoptedService;
import com.sacc.service.BoxCollectedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;

/**
 * @author 滚~韬
 * @date 2022/4/14 14:11
 */
@RestController
@RequestMapping("/box/adopted")
public class BoxAdoptedController {
    @Autowired
    private BoxAdoptedService boxAdoptedService;
    @Autowired
    private BoxCollectedService boxCollectedService;
    //获取已经认养的蜂箱id
    @GetMapping("/getadopted")
    List<Integer> boxIdsadopted(@RequestParam String openId){
        return boxAdoptedService.getBoxIds(openId);
    }
    //用已经收藏的蜂箱去掉已经认养的蜂箱id
    @GetMapping("/getunadopted")
    List<Integer> boxIdsUnadopted(@RequestParam String openId){
        //返回待认养的蜂箱
        return  boxCollectedService.getBoxIdsCollected(openId);
    }
    //认养蜂箱
//    @PostMapping("/toadopt")
//    CommonResult Adopt(@RequestBody BoxAdopted boxAdopted){
//        return boxAdoptedService.Adopt(boxAdopted);
//    }
    @PostMapping("/toadopt")
    CommonResult Adopt(@RequestParam String openId,@RequestParam String boxId){
        return boxAdoptedService.Adopt(openId,boxId);
    }
}
